home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Programmation
/
Alpha ƒ
/
Tcl
/
SystemCode
/
menusLite.tcl
< prev
next >
Wrap
Text File
|
1996-01-15
|
7KB
|
331 lines
# My menus.
menu -n File -p fileMenuProc {
"/Nnew"
"/Oopen╔"
{menu -m -n filesets {}}
"<S/Wclose"
"<S<I<O/WcloseAll"
"(-"
"<S/Ssave"
"<S<I<O/SsaveAll"
"<SsaveAs╔"
"<E<SrevertToBackup"
"<Srevert"
"(-"
"pageSetup╔"
"/Pprint╔"
"(-"
"/Qquit"
}
proc fileMenuProc {menu item} {
if {$item == "open"} {
findFile
} elseif {$item == "close"} {
killWindow
} else {
$item
}
}
menu -n Edit {
"/Zundo"
"/Z<I<Oredo"
{menu -n emacs {}}
"(-"
"/X<Scut"
"/X<S<I<Ocut&Append"
"/C<Scopy"
"/C<S<I<Ocopy&Append"
"/V<Spaste"
"/V<S<I<OpastePop"
"/A<SselectAll"
"/A<S<I<OselectParagraph"
"clear"
"(-"
"/=selectLast"
"/`<Stwiddle"
"/`<S<I<OtwiddleWords"
}
proc selectLast {} { markHilite }
#% {/[<SshiftLeft}
#% {/[<S<I<OshiftLeftSpace}
#% {/]<SshiftRight}
#% {/]<S<I<OshiftRightSpace}
menu -n Search {
"/F<Sfind╔"
"/F<S<I<OsearchStart"
"/G<SfindAgain"
"/G<S<I<OfindAgainBackward"
"/H<I<OfindInNextFile"
"/E<SenterSearchString"
"/E<S<I<OenterReplaceString"
"(-"
"/S<BquickFind"
"/R<BreverseQuickFind"
"(-"
"/R<Sreplace"
"/R<S<I<OreplaceAll"
"/Hreplace&FindAgain"
"(-"
"/,<BpushPosition"
"/.<BpopPosition"
"/G<IgotoLine"
}
# ==== NOTE: rectMarkHilite, onespace, centerRedraw, doTab
menu -n Text {
"/I<SfillParagraph"
"/I<S<O<IwrapParagraph"
"/I<S<O<I<BsentenceParagraph"
"/U<S<OfillRegion"
"/U<S<I<OwrapRegion"
"<E<SupcaseRegion"
"<SdowncaseRegion"
"(-"
"<SreverseSort"
"<SsortLines"
"/L<I<OspellcheckWindow"
"zapInvisibles"
"<SspacesToTabs"
"<StabsToSpaces"
"(-"
"/D<ScommentLine"
"/D<S<I<OuncommentLine"
"<SuncommentBox"
"<ScommentBox"
"<S<EuncommentParagraph"
"<ScommentParagraph"
"(-"
"textToAlpha"
}
proc strip {arg} {
if {[regsub -all {\\([][\{\}])} $arg {\1} v]} {return $v}
return $arg
}
#===============================================================================
proc helpMenu {item} {
global HOME
edit -r "$HOME:Help:$item"
}
set men { "Quick Start" "Readme" "Changes" "(-" }
foreach f [lsort -ignore [glob "$HOME:Help:*"]] {
set f [file tail $f]
if {[lsearch $men $f] < 0} {
lappend men $f
}
}
foreach f $men {
addHelpMenu $f
}
unset men
#===============================================================================
proc escapeSpaces {str} {
regsub -all { } $str {\ } str2
return $str2
}
proc buildSwitches {} {
global switchApps
menu -m -n switchTo -p switchProc {"<O<I/NNow╔" "Add╔" "Remove╔" "(-"}
if {[info exists switchApps] && [llength $switchApps]} {
foreach app $switchApps {
lappend names [file tail $app]
}
foreach name [lsort -ignore $names] {
addMenuItem -m -l "blah" switchTo $name
}
}
}
proc switchProc {menu name} {
global switchTo switchApps
if {$name == "Add"} {
set fname [getfile "Pick an app:"]
lappend switchApps $fname
addDef switchApps $switchApps
buildSwitches
} elseif {$name == "Remove"} {
foreach app $switchApps {
lappend apps [file tail $app]
}
set name [listpick -p "Remove which app?" $apps]
if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
set switchApps [lreplace $switchApps $ind $ind]
addDef switchApps $switchApps
buildSwitches
}
} elseif {$name == "Now"} {
switchApp
} else {
if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
if {[catch {switchTo $name}]} {
launch -f [lindex $switchApps $ind]
}
}
}
}
proc winTileProc {menu item} {
win$item
}
menu -n $winMenu -p menuWin {
"//<SsinglePage"
"//<Szoom"
"<S/;chooseAWindow"
"/Y<O<Iiconify"
{menu -n arrange -p winTileProc {
"/Jvertically^1"
"/J<O<Ihorizontally^2"
"tiled^3"
"overlay^4"
"(-"
}}
"modifyModeFlags╔"
"(-"
"/isetFontsTabs╔"
"/jsplitWindow"
"/ltoggleScrollbar"
"(-"
}
# We may be reloading, so add whatever windows we have
if {[info exists winNameToNum]} {
set nms [array names winNameToNum]
foreach name $nms {
regexp {[^:]*$} $name item
set num $winNameToNum($name)
if {$num < 10} {
addMenuItem -m $winMenu /$num$item
} else {
addMenuItem -m $winMenu $item
}
}
}
insertMenu "File"
insertMenu "Edit"
insertMenu "Search"
insertMenu "Text"
catch {enableMenuItem NamedClipboards paste off}
menu -n $fsetMenuName {};
insertMenu $winMenu
# catch {insertMenu $helpMenu}
menu -n $toolserverMenu {}
#===============================================================================
# Stuff that needs to be here for AlphaLite.
#===============================================================================
proc rebuildTclIndices {} {
global auto_path
set d [pwd]
# do we really need the next line? Alpha's original uses it.
cd
foreach dir $auto_path {
# if directory exists
if { ![catch { cd $dir } ] } {
# if there are any files
if { ![catch { glob *.*tcl } ] } {
message "Building [file tail $dir] index╔"
# if the '[incr tcl]' version exists, use that
# use 'catch' also in case directory is write-protected
if [catch { itcl_mkindex : *.*tcl } ] {
# else try the normal one
catch { auto_mkindex : *.*tcl }
}
}
}
}
# redo the auto-mode-file connections (see "smarterSource.tcl")
message "Building the mode-file dependency array"
catch {autoModeFiles}
message ""
cd $d
}
proc traceTclProc {} {
global tclMenu
if {[llength [traceFunc status]]>2} {
catch {markMenuItem $tclMenu {traceTclProc╔} off}
catch {enableMenuItem $tclMenu dumpTraces off}
if {[string length [set data [traceDump]]]} {
if {[askyesno "Dump traces?"] == "yes"} {
dumpTraces [string trimright [lindex [traceFunc status] 3] {,}] $data
setWinInfo dirty 0
}
}
traceFunc off
message "Tracing off."
return
}
if {[llength [winNames]] && [string length [set sel [getSelect]]]} {
set func [listpick -L $sel -p {Func Name:} [lsort -ignore [info procs]]]
} else {
set func [listpick -p {Func Name:} [lsort -ignore [info procs]]]
}
if {![string length $func]} return
traceFunc on $func ""
catch {markMenuItem $tclMenu {traceTclProc╔} on}
catch {enableMenuItem $tclMenu dumpTraces on}
message "Tracing '$func'╔"
}
proc dumpTraces {{name ""} {data ""}} {
if {![string length $name]} {
set name [string trimright [lindex [traceFunc status] 3] {,}]
}
if {![string length $data]} {
set data [traceDump]
}
if {![string length $data]} {
message "Trace buffer empty"
} else {
new -n "* Trace '$name' *"
insertText $data
setWinInfo dirty 0
goto 0
}
}
proc carriageReturn {} {
global mode
global indentOnCR
set indentString ""
deleteText [getPos] [selEnd]
if {$indentOnCR} {
set pos [getPos]
set text [getText [lineStart $pos] $pos]
for {set i 0; set len [string length $text]} {$i <= $len} {incr i} {
set c [string index $text $i]
if {($c != "\t") && ($c != "\ ")} {
set indentString [string range $text 0 [expr $i-1]]
break
}
}
}
insertText "\r" $indentString
}